package com.bjfu.demo.controller;

import com.bjfu.demo.dto.StatisticRawResult;
import com.bjfu.demo.service.NewStatisticServiceImpl;
import com.bjfu.demo.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class NewStatisticController {
    @Autowired
    private NewStatisticServiceImpl newStatisticService;

    @GetMapping("/getYear1")
    public Result<List<StatisticRawResult>> getYear() {
        List<StatisticRawResult> statisticByYear = newStatisticService.getStatisticByYear();
        if (statisticByYear != null && statisticByYear.size() != 0) {
            return Result.ok("查询成功", statisticByYear);
        }
        return Result.fail("查询失败");
    }

    @GetMapping("/getSeason1")
    public Result<List<StatisticRawResult>> getSeason() {
        List<StatisticRawResult> statisticBySeason = newStatisticService.getStatisticBySeason();
        if (statisticBySeason != null && statisticBySeason.size() != 0) {
            return Result.ok("查询成功", statisticBySeason);
        }
        return Result.fail("查询失败");
    }

    @GetMapping("/getMonth1")
    public Result<List<StatisticRawResult>> getMonth() {
        List<StatisticRawResult> statisticByMonth = newStatisticService.getStatisticByMonth();
        if (statisticByMonth != null && statisticByMonth.size() != 0) {
            return Result.ok("查询成功", statisticByMonth);
        }
        return Result.fail("查询失败");
    }
}
